home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Development Tools & Languages / HyperCard Related / APDA HyperCard Toolkits / HyperCard Video Toolkit 2.0 / HVT #2 / Advanced Material / Video Sources / stepVideo.p < prev    next >
Encoding:
Text File  |  1995-02-07  |  3.6 KB  |  137 lines  |  [TEXT/MPS ]

  1. (*
  2.     stepVideo n,m - Step the display n frames, and do it m times.
  3.  
  4.     To compile and link this file using Macintosh Programmer's Workshop,
  5.  
  6.         pascal -w stepVideo.p
  7.  
  8.         link -m ENTRYPOINT -o HyperCommands -rt XCMD=8007 -sn Main=stepVideo ∂
  9.             stepVideo.p.o "{MPW}"Libraries:interface.o "{MPW}"PLibraries:PasLib.o
  10.  
  11.     Copyright © 1987,88 Apple Computer, Inc.
  12.  
  13.     9/87 - Initial coding by Harry R. Chesley.
  14.     2/88 - Changed for new interface specification by Harry R. Chesley.
  15. *)
  16.  
  17. {$R-}
  18.  
  19. {$S stepVideo }     { Segment name must be the same as the command name. }
  20.  
  21. unit DummyUnit;
  22.  
  23. interface
  24.  
  25. uses MemTypes, QuickDraw, OSIntf, HyperXCmd;
  26.  
  27. procedure EntryPoint(paramPtr: XCmdPtr);
  28.     
  29. implementation
  30.  
  31. type
  32.  
  33. Str31 = String[31];
  34.  
  35. procedure stepVideo(paramPtr: XCmdPtr); forward;
  36.  
  37. procedure EntryPoint(paramPtr: XCmdPtr);
  38.  
  39.     begin
  40.         stepVideo(paramPtr);
  41.     end;
  42.  
  43. procedure stepVideo(paramPtr: XCmdPtr);
  44.  
  45.     var numberOfParms: integer;        { Number of input parameters. }
  46.         stepSize: longInt;                        { How many frames to step at each iteration. }
  47.         repeatCount: longInt;                { How many times to iterate. }
  48.         iter: longInt;                                { Iteration index. }
  49.         stepIter: integer;                        { Interation step index. }
  50.         blankSearch: boolean;                { Whether to blank on searches. }
  51.         theFrame: longInt;                    { With big jumps, the current frame number. }
  52.         str: str255;                                { Misc. string. }
  53.         oldMode: str255;                        { The old frame/chapter/time mode. }
  54.  
  55.     {$I XCmdGlue.inc}
  56.  
  57.     procedure Fail(errMsg: Str255); { set theResult and quit }
  58.         begin
  59.             paramPtr^.returnValue := PasToZero(errMsg);
  60.             exit(stepVideo);
  61.         end;
  62.  
  63.     {$I VideoUtil.inc}
  64.  
  65.     begin
  66.         numberOfParms := paramPtr^.paramCount;
  67.         if numberOfParms > 2 then Fail('parameter count is not 0-2');
  68.  
  69.         { Get the step size. }
  70.         if numberOfParms > 0 then stepSize := GetLongParm(1)
  71.         else stepSize := 1;
  72.         if stepSize = 0 then stepSize := 1;
  73.  
  74.         { Get the repeat count. }
  75.         if numberOfParms > 1 then repeatCount := GetLongParm(2)
  76.         else repeatCount := 1;
  77.  
  78.         { Remember the old mode and change to frame mode. }
  79.         GetStrGlobal('videoMode',oldMode);
  80.         if oldMode = '' then oldMode := 'frameMode';
  81.         videoCmd('control','frameMode');
  82.  
  83.         { If we're hopping, get the current frame number. }
  84.         if (stepSize > 9) or (stepSize < -9) then
  85.             begin
  86.                 { Clear out any pending input. }
  87.                 EvalAndDispose('recvUpTo(empty,0,empty)');
  88.                 { Get the frame number. }
  89.                 str := videoFunc('frame','');
  90.                 if StringEqual(str,'noAnswer') then
  91.                     begin
  92.                         videoCmd('control',oldMode);
  93.                         Fail('noAnswer');
  94.                     end;
  95.                 theFrame := StrToLong(str);
  96.             end;
  97.  
  98.         { Remember the blanking. }
  99.         GetStrGlobal('blankNextVideo',str);
  100.         blankSearch := str <> '';
  101.  
  102.         for iter := 1 to repeatCount do
  103.             begin
  104.                 { Step it... }
  105.                 if (stepSize >= 1) and (stepSize <= 9) then
  106.                     begin
  107.                         if blankSearch then videoCmd('control','pictureOff');
  108.                         for stepIter := 1 to stepSize do videoCmd('step','1');
  109.                         if blankSearch then videoCmd('control','pictureOn');
  110.                     end
  111.                 else if (stepSIze <= -1) and (stepSize >= -9) then
  112.                     begin
  113.                         if blankSearch then videoCmd('control','pictureOff');
  114.                         for stepIter := 1 to -stepSize do videoCmd('step','-1');
  115.                         if blankSearch then videoCmd('control','pictureOn');
  116.                     end
  117.                 else
  118.                     begin
  119.                         { If we were blanking, make sure the global is still set. }
  120.                         if blankSearch then SetStrGlobal('blankNextVideo','true');
  121.                         { Get the next frame in the sequence. }
  122.                         theFrame := theFrame + stepSize;
  123.                         if theFrame < 0 then leave;
  124.                         { Search to it. }
  125.                         videoCmd('search',LongToStr(theFrame));
  126.                     end;
  127.             end;
  128.  
  129.         { Clear out blanking. }
  130.         SetStrGlobal('blankNextVideo','');
  131.  
  132.         { Restore the mode. }
  133.         videoCmd('control',oldMode);
  134.     end;
  135.  
  136. end.
  137.